package com.yanqu.road.server.cmd.orewar.cross;

import com.yanqu.road.entity.crossorewar.CrossUserOrePit;
import com.yanqu.road.pb.orewar.OreWarProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.OreWarModule;
import com.yanqu.road.server.pb.OreWarPb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

import java.util.ArrayList;
import java.util.List;

@Cmd(code = Protocol.S_CROSS_ORE_WAR_SELF_PIT, desc = "跨服返回玩家自己的信息")
public class CrossOreGetSelfPitMsgCmd extends AbstractCommand {

	private int activityId;

	List<CrossUserOrePit> crossUserOrePitList = new ArrayList<>();

	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		OreWarProto.CrossOrePitListMsg crossSyncMsg = OreWarProto.CrossOrePitListMsg.parseFrom(packet.getBytes());
		activityId = crossSyncMsg.getActivityId();
		crossUserOrePitList = OreWarPb.parseCrossOrePitList(crossSyncMsg.getOrePitListList());

		//检验坑位门客占领是否一致
		player.getModule(OreWarModule.class).checkCrossPatronsDispatch(activityId,crossUserOrePitList);
		player.getModule(OreWarModule.class).syncCrossOrePit(activityId,crossUserOrePitList, false, true);
		player.getModule(OreWarModule.class).syncUserOreWarPatronsData(activityId);
	}

	@Override
	public void sendData(GamePlayer player) {

	}

}
